<?php
/**
 * 
 * IndexAction.class.php (前台首页)
 *
 * @package      	jgsat
 * @author          liuxun QQ:147613338 <admin@jgsat.cn>
 * @copyright     	Copyright (c) 2008-2011  (http://www.jgsat.com)
 * @license         http://www.jgsat.com/license.txt
 * @version        	jgsat企业网站管理系统 v2.1 2011-03-01 jgsat.cn $
 */
if(!defined("JGsat")) exit("Access Denied");
class StoreAction extends BaseAction
{
    function _initialize()
    {	
	parent::_initialize();
    }
    
    public function index()
    {
        $id =intval($_REQUEST['id']);
        if(empty($id))$this->error("缺少参数!");
	if(empty($catid)) $catid =  intval($_REQUEST['cid']);
	if(empty($bid)) $bid =  intval($_REQUEST['bid']);
        $module="Product";
        $this->assign('module_name',$module);
        $store=M("User")->find($id);
        $where=" status=1 and userid=".$id;
        if($catid){
            $where .= " and catid=".$catid;            
            $brandlist=M("Brand")->where("catid=".$catid)->order("id")->select();
            $this->assign('brandlist',$brandlist);
        }
        if($bid){
            $where .= " and p_brand=".$bid;	
        }        
        $this->assign ('seo_title',$store["companyname"]);
        $this->assign('catid',$catid);
        $this->assign('bid',$bid);
        $this->assign('store',$store);
        

        $this->dao= M($module);
        $count = $this->dao->where($where)->count();
        if($count){
                import ( "@.ORG.Page" );
                $listRows =  32;
                $page = new Page ( $count, $listRows );
                $pages = $page->preshow();
                $field =  $this->module[$this->mod[$module]]['listfields'];
                $field =  "*";
                $list = $this->dao->field($field)->where($where)->order("id desc")->limit($page->firstRow . ',' . $page->listRows)->select();
                $this->assign('pages',$pages);
                $this->assign('list',$list);
                $this->assign('jgcount',$count);
        }       
        
        $uid=intval($_REQUEST['uid']);
        if($uid>0){
            $this->assign('uid',$uid);
        }
        $this->display();		
    }
    public function userindex()
    {
        $id =intval($_REQUEST['id']);
        if(empty($id))$this->error("缺少参数!");
	if(empty($catid)) $catid =  intval($_REQUEST['cid']);
        $module="Share";
        $this->assign('module_name',$module);
        $store=M("User")->find($id);
        $where=" status=1 and userid=".$id;
        if($catid){
            $where .= " and catid=".$catid;           
        }   
        $this->assign ('seo_title',$store["nickname"]);
        $this->assign('catid',$catid);
        $this->assign('store',$store);
        

        $this->dao= M($module);
        $count = $this->dao->where($where)->count();
        if($count){
                import ( "@.ORG.Page" );
                $listRows =  32;
                $page = new Page ( $count, $listRows );
                $pages = $page->show();
                $field =  $this->module[$this->mod[$module]]['listfields'];
                $field =  "*";
                $list = $this->dao->field($field)->where($where)->order("id desc")->limit($page->firstRow . ',' . $page->listRows)->select();
                $this->assign('pages',$pages);
                $this->assign('list',$list);
                $this->assign('jgcount',$count);
        }        
        $this->display();		
    }
}
?>